package com.example.demo;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * Created by yuzhanwu.
 * Created on 2017/6/16.
 */
@Component
class WebConfigurer extends WebMvcConfigurerAdapter {
    @Autowired
    FilePathConfig filePathConfig;
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/image/**").addResourceLocations("file:///"+filePathConfig.getPath());
        //校本资源的下载
        registry.addResourceHandler("/download/**").addResourceLocations("file:///"+filePathConfig.getPath());
        //校本资源预览
        registry.addResourceHandler("/preview/image/**").addResourceLocations("file:///"+filePathConfig.getPreviewPath());
    }

}
